Skip to content

feat(grpc): Support span streaming#6204

Open
alexander-alderman-webb wants to merge 12 commits intomasterfrom
webb/grpc/span-first
Open

feat(grpc): Support span streaming#6204
alexander-alderman-webb wants to merge 12 commits intomasterfrom
webb/grpc/span-first

Conversation

@alexander-alderman-webb
Copy link
Copy Markdown
Contributor

@alexander-alderman-webb alexander-alderman-webb commented May 5, 2026

Description

In the streaming path, use

  • rpc.method instead of method
  • rpc.response.status_code instead of code

Dropped attributes:

  • type

Adapting Tests

sed commands used for converting transaction context managers:

  • sed -i '' 's/with start_transaction() as transaction:/with sentry_sdk.traces.start_span(name="custom parent") as span:/g'
  • sed -i '' 's/with sentry_sdk.start_transaction() as transaction:/with sentry_sdk.traces.start_span(name="custom parent") as span:/g'
  • sed -i '' 's/with start_transaction():/with sentry_sdk.traces.start_span(name="custom parent"):/g'
  • sed -i '' 's/with start_transaction(name="custom_transaction"):/with sentry_sdk.traces.start_span(name="custom parent"):/g'

sed commands used for converting specific attributes:

  • sed -i '' '/"type": /d'
  • sed -i '' 's/code/rpc.response.status_code/g'
  • sed -i '' 's/method/rpc.method/g'

sed commands used for converting event capture:

  • sed -i '' 's/(event, _) = events/(event, ) = (item.payload for item in items if item.type == "event")/g'
  • sed -i '' 's/local_transaction["spans"]/spans/g'
  • sed -i '' 's/events.read_event()/span = events.read_event()["payload"]/g'
  • sed -i '' 's/events = capture_events_forksafe()/items = capture_items_forksafe("event", "transaction", "span")/g'
  • sed -i '' 's/capture_events_forksafe,/capture_items_forksafe,/g'
  • sed -i '' 's/event["spans"]/spans/g'
  • sed -i '' 's/events = capture_events()/items = capture_items("event", "transaction", "span")/g'
  • sed -i '' 's/capture_events,/capture_items,/g'

sed commands used for converting op:

  • sed -i '' 's/["op"]/["attributes"]["sentry.op"]/g'

sed commands used for converting origin:

  • sed -i '' 's/["contexts"]["trace"]["origin"]/["attributes"]["sentry.origin"]/g'

sed commands used for converting description:

  • sed -i '' 's/description/name/g'

sed commands used for converting data to attributes:

  • sed -i '' 's/data/attributes/g'

sed commands for converting trace id:

  • sed -i '' 's/["contexts"]["trace"]["trace_id"]/["trace_id"]/g'

other test changes:

  • sed -i '' 's/, channel = grpc_server_and_channel/, channel = await grpc_server_and_channel(span_streaming)/g'
  • sed -i '' 's/events.read_event()/items = items.read_event()/g'
  • sed -i '' 's/events.write_file.close()/items.write_file.close()/g'

Issues

Closes #6027

Reminders

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 5, 2026

Codecov Results 📊

13 passed | Total: 13 | Pass Rate: 100% | Execution Time: 8.87s

📊 Comparison with Base Branch

Metric Change
Total Tests
Passed Tests
Failed Tests
Skipped Tests

✨ No test changes detected

All tests are passing successfully.

❌ Patch coverage is 1.92%. Project has 15081 uncovered lines.
❌ Project coverage is 31.25%. Comparing base (base) to head (head).

Files with missing lines (5)
File Patch % Lines
server.py 0.00% ⚠️ 70 Missing
client.py 0.00% ⚠️ 57 Missing
client.py 0.00% ⚠️ 54 Missing
server.py 0.00% ⚠️ 44 Missing
consts.py 99.48% ⚠️ 2 Missing
Coverage diff
@@            Coverage Diff             @@
##          main       #PR       +/-##
==========================================
- Coverage    31.33%    31.25%    -0.08%
==========================================
  Files          190       190         —
  Lines        21877     21936       +59
  Branches      7360      7372       +12
==========================================
+ Hits          6853      6855        +2
- Misses       15024     15081       +57
- Partials       579       579         —

Generated by Codecov Action

Comment thread tests/integrations/grpc/test_grpc_aio.py
Comment thread sentry_sdk/integrations/grpc/aio/server.py
@alexander-alderman-webb alexander-alderman-webb marked this pull request as ready for review May 5, 2026 16:01
@alexander-alderman-webb alexander-alderman-webb requested a review from a team as a code owner May 5, 2026 16:01
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 049f1de. Configure here.

Comment thread sentry_sdk/integrations/grpc/aio/client.py Outdated
Comment thread tests/integrations/grpc/test_grpc_aio.py
Comment thread tests/integrations/grpc/test_grpc_aio.py Outdated
Comment thread tests/integrations/grpc/test_grpc_aio.py Outdated
@alexander-alderman-webb alexander-alderman-webb marked this pull request as draft May 6, 2026 10:35
Comment thread tests/integrations/grpc/test_grpc_aio.py
Comment thread tests/integrations/grpc/test_grpc_aio.py
@alexander-alderman-webb alexander-alderman-webb marked this pull request as ready for review May 6, 2026 14:43
Copy link
Copy Markdown
Contributor

@sentrivana sentrivana left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Can you please also add parent_span=None to sentry_sdk.traces.start_span calls where there were transactions previously? 🙏🏻

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Migrate grpc to span first

2 participants